from config import path_cfg


class RegLoginApi(object):

    def __init__(self, session):
        self.session = session
        self.img_verify_url = path_cfg.P2P_URL + path_cfg.IMG_VERIFY_URL
        self.sms_verify_url = path_cfg.P2P_URL + path_cfg.SMS_VERIFY_URL
        self.login_url = path_cfg.P2P_URL + path_cfg.LOGIN_URL
        self.reg_url = path_cfg.P2P_URL + path_cfg.REG_URL

    # 获取图片验证码
    def get_img_verify_code(self, path_params):
        return self.session.get(self.img_verify_url + str(path_params))

    # 获取短信验证码接口
    def get_sms_verify_code(self, req_body):
        return self.session.post(url=self.sms_verify_url, data=req_body)

    # 注册接口
    def user_register(self, req_body):
        return self.session.post(url=self.reg_url, data=req_body)

    # 登录接口
    def user_login(self, req_body):
        return self.session.post(url=self.login_url, data=req_body)

